import App from './App'
import uView from '@/uni_modules/uview-ui'
import {
	CurrentRole,
	APP_ROLE
} from "./config"
import store from './store';
import globalMixin from '@/mixin/global-mixin'
import en from './locale/en.json'
import ar from './locale/ar.json'
const messages = {
	en,
	ar
}
console.log(uni.getLocale())

let i18nConfig = {
	// locale: uni.getLocale() || 'en', //uni.getLocale(), // 获取已设置的语言
	locale:uni.getStorageSync('language') || 'en',
	messages
}
Vue.mixin(globalMixin);
Vue.use(uView)

// #ifndef VUE3
import Vue from 'vue'
import './uni.promisify.adaptor'
Vue.config.productionTip = false
Vue.prototype.$store = store
Vue.prototype.$isAgent = CurrentRole == APP_ROLE.Agent

import VueI18n from 'vue-i18n' // v8.x
Vue.use(VueI18n)
const i18n = new VueI18n(i18nConfig)

App.mpType = 'app'
const app = new Vue({
	store,
	i18n,
	...App
})
app.$mount()
// #endif

// #ifdef VUE3
import {
	createSSRApp
} from 'vue'
import {
	APP_ROLE,
	CurrentRole
} from './config'
export function createApp() {
	const app = createSSRApp(App)
	return {
		app
	}
}
// #endif